import 'dart:convert';

CartListModel cartListModelFromJson(String str) =>
    CartListModel.fromJson(json.decode(str));

String cartListModelToJson(CartListModel data) => json.encode(data.toJson());

class CartListModel {
  int code;
  String? message;
  List<CartData> data;

  CartListModel({
    required this.code,
    required this.message,
    required this.data,
  });

  factory CartListModel.fromJson(Map<String, dynamic> json) => CartListModel(
        code: json["code"],
        message: json["message"],
        data:
            List<CartData>.from(json["data"].map((x) => CartData.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "code": code,
        "message": message,
        "data": List<dynamic>.from(data.map((x) => x.toJson())),
      };
}

class CartData {
  int id;
  int fid;
  int uid;
  int number;
  double amount;
  double price;
  String coverUrl;
  String name;
  String ename;
  String unit;
  String createTime;

  CartData({
    required this.id,
    required this.fid,
    required this.uid,
    required this.number,
    required this.amount,
    required this.price,
    required this.coverUrl,
    required this.name,
    required this.ename,
    required this.unit,
    required this.createTime,
  });

  factory CartData.fromJson(Map<String, dynamic> json) => CartData(
        id: json["id"],
        fid: json["fid"],
        uid: json["uid"],
        number: json["number"],
        amount: json["amount"],
        price: json["price"],
        coverUrl: json["coverUrl"],
        name: json["name"],
        ename: json["ename"],
        unit: json["unit"],
        createTime: json["createTime"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "fid": fid,
        "uid": uid,
        "number": number,
        "amount": amount,
        "price": price,
        "coverUrl": coverUrl,
        "name": name,
        "ename": ename,
        "unit": unit,
        "createTime": createTime,
      };
}
